import java.util.Random;

public class test57 {
    /*
    生成验证码
    内容:可以是小写字母,也可以是大写字母,还可以是数字
    规则:长度为5
    内容中是四4位字母,1位数字
    其中数字只有1位,但是可以出现在任意位置*/
    public static void main(String[] args) {
        char[] str1 = new char[52];
        for (int i = 0; i < str1.length; i++) {
            if (i <= 25) {
                str1[i] = (char) ('a' + i);
            } else {
                str1[i] = (char) ('A' + i - 26);
            }
        }
        StringBuilder sb = new StringBuilder();
        Random r = new Random();
        for (int i = 0; i < 4; i++) {
            int a = r.nextInt(str1.length);
            sb.append(str1[a]);
        }
        int number = r.nextInt(9);
        sb.append(number);
        String str2 = sb.toString();
        char[] str3 = str2.toCharArray();
        char first = str3[str3.length - 1];
        int b = r.nextInt(str3.length);
        str3[str3.length-1] = str3[b];
        str3[b] = first;
        System.out.println(str3);
    }
 }

